/* bsave a file from hires screen 2 */
#include <console.h>
#include <stdio.h>
#include <fcntl.h>
#include <dos33.h>
#include <sgtty.h>
#include <device.h>

/*

When open is used to creat a file under DOS 3.3, param3 is the file's type:

    Param3,hex    File type

    00            Text
    01            Integer basic
    02            Applesoft basic
    04            Binary
    08            Relocatable
    10            S-type file
    20            A-type file
    40            B-type file

*/


bsave(savex)
char *savex;
{
    int fh, c=-1, fla = 0x2000;

    if((fh=open(savex, O_WRONLY|O_TRUNC|O_CREAT,4)) != -1)
        {
	    c = write(fh,&fla,2);
	    if (c==2)c = write(fh,&fla,2);
        if (c==2)c = write(fh,(char *)0x2000,0x2000);
        close(fh);
        if (c!= 0x2000) c = -2;
        else c = 0;
        }
        return c;
}

